package com.scrumtrek.trainings.tdd;

import com.google.common.collect.Lists;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: zeliboba
 * Date: 11.09.13
 * Time: 12:28
 * To change this template use File | Settings | File Templates.
 */
public class Store<T extends Item> implements IStore<T> {
    private List<T> itemList = Lists.newArrayList();
    private PaySystem paySystem;

    @Override
    public void setPaySystem(PaySystem paySystem) {
        this.paySystem = paySystem;
    }

    @Override
    public void addItem(T item) {
        itemList.add(item);
    }

    @Override
    public void sell(T item){
        paySystem.increaseProfit(item.getPrice());
        itemList.remove(item);
    }

    @Override
    public int getTotalItemsAmount() {
        return itemList.size();
    }

    public List<T> getItemList() {
        return itemList;
    }

    public PaySystem getPaySystem() {
        return paySystem;
    }
}
